package com.yunxin.admin.system.infra.persistence.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunxin.admin.system.domain.model.user.*;
import com.yunxin.admin.system.infra.framework.mybatisplus.DataPermission;
import com.yunxin.admin.system.infra.persistence.entity.SysRoleDO;
import com.yunxin.admin.system.infra.persistence.entity.SysUserDO;
import com.yunxin.admin.system.infra.persistence.entity.query.condition.UserMerchantPageCondition;
import com.yunxin.admin.system.infra.persistence.entity.query.condition.UserPageCondition;
import com.yunxin.admin.system.infra.persistence.entity.query.result.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 用户持久层
 *
 * @author zero°
 * @since 2023-05-22
 */
@Mapper
public interface SysUserMapper extends BaseMapper<SysUserDO> {

    /**
     * 获取用户分页列表
     *
     * @param page page
     * @param queryParams 查询参数
     * @return Page<UserResult>
     */
    //@DataPermission(deptAlias = "u")
    Page<UserPageResult> getUserPage(Page<User> page, @Param("queryParams") UserPageCondition queryParams);

    /**
     * 获取商户用户分页列表
     *
     * @param page page
     * @param queryParams 查询参数
     * @return Page<UserMerchantResult>
     */
    Page<UserMerchantInfoResult> getUserMerchantPage(Page<User> page, @Param("queryParams") UserMerchantPageCondition queryParams);

    /**
     * 获取用户表单详情
     *
     * @param userId 用户ID
     * @return
     */
    UserInfoResult getUserInfoByIdAndTeamId(@Param("userId") Long userId );

    /**
     * 根据用户名获取认证信息
     *
     * @param queryValue queryValue
     * @param queryType queryType 1-用户名 2-手机号
     * @return UserAuthInfoResult
     */
    UserAuthInfoResult getUserAuthInfo(@Param("queryValue") String queryValue,
                                       @Param("queryType") Integer queryType);

    /**
     * 获取导出用户列表
     *
     * @param queryParams queryParams
     * @return List<UserExportResult>
     */
    @DataPermission(deptAlias = "u")
    List<UserExportResult> listExportUsers(@Param("queryParams") UserPageCondition queryParams);

    /**
     * 查询用户角色
     * @param userId
     * @return
     */
    List<SysRoleDO>  getUserRoleId(@Param("userId") Long userId);

    /**
     * 根据userId查询角色
     * @param userId
     * @return
     */
    List<String> getUserRoleName(@Param("userId") Long userId);
}
